package com.sikao.app.view;

import android.view.View;

import com.daimajia.slider.library.Animations.BaseAnimationInterface;
import com.nineoldandroids.animation.ObjectAnimator;
import com.nineoldandroids.animation.ValueAnimator;
import com.nineoldandroids.view.ViewHelper;

/**
 * Created by y50 on 2016/4/19.
 */
public class MyCustomAnimation implements BaseAnimationInterface {

	@Override
	public void onPrepareCurrentItemLeaveScreen(View current) {
		View descriptionLayout = current.findViewById(com.daimajia.slider.library.R.id.description_layout);
		if(descriptionLayout!=null){
			current.findViewById(com.daimajia.slider.library.R.id.description_layout).setVisibility(View.INVISIBLE);
		}
	}

	/**
	 * When next item is coming to show, let's hide the description layout.
	 * @param next
	 */
	@Override
	public void onPrepareNextItemShowInScreen(View next) {
		View descriptionLayout = next.findViewById(com.daimajia.slider.library.R.id.description_layout);
		if(descriptionLayout!=null){
			next.findViewById(com.daimajia.slider.library.R.id.description_layout).setVisibility(View.INVISIBLE);
		}
	}


	@Override
	public void onCurrentItemDisappear(View view) {

	}

	/**
	 * When next item show in ViewPagerEx, let's make an animation to show the
	 * description layout.
	 * @param view
	 */
	@Override
	public void onNextItemAppear(View view) {

		View descriptionLayout = view.findViewById(com.daimajia.slider.library.R.id.description_layout);
		if(descriptionLayout!=null){
			float layoutY = ViewHelper.getY(descriptionLayout);
			view.findViewById(com.daimajia.slider.library.R.id.description_layout).setVisibility(View.INVISIBLE);
			/*ValueAnimator animator = ObjectAnimator.ofFloat(
					descriptionLayout,"y",layoutY + descriptionLayout.getHeight(),
					layoutY).setDuration(500);
			animator.start();*/
		}

	}
}
